package com.texplose.controller;

import com.texplose.entity.enums.AppHttpCodeEnum;
import com.texplose.entity.vo.ResponseResult;
import com.texplose.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author : lyj
 * @Timer : 2022/5/18
 * @Description :
 * 图片上传接口
 */
@RestController
@RequestMapping("/api/file")
public class FileAPIController {

    @Autowired
    private FileService fileService;

    @PostMapping("/upload")
    public ResponseResult uploadFile(MultipartFile file){
        if (file==null){
            return ResponseResult.errorResult(AppHttpCodeEnum.FILE_IS_NULL);
        }else {
            return fileService.upload(file);
        }
    }





}
